<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>打印变量的相关信息</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.unset.html">« unset</a></li>
      <li style="float: right;"><a href="function.var-export.html">var_export »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.var.html">Variable handling 函数</a></li>
    <li>打印变量的相关信息</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.var-dump" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">var_dump</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">var_dump</span> &mdash; <span class="dc-title">打印变量的相关信息</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.var-dump-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>var_dump</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>, <span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">...$values</code></span>): <span class="type"><span class="type void">void</span></span></div>

  <p class="simpara">
     此函数显示关于一个或多个表达式的结构信息，包括表达式的类型与值。数组和对象将递归展开值，通过缩进显示其结构。
  </p>
  <p class="simpara">
   对象的所有公共、私有和受保护的属性都会在输出中返回，除非该对象实现了
   <a href="language.oop5.magic.html#language.oop5.magic.debuginfo" class="link">__debugInfo()</a> 方法。
  </p>
  <div class="tip"><strong class="tip">小技巧</strong><p class="simpara">和直接将结果输出到浏览器一样，可使用<a href="book.outcontrol.html" class="link">输出控制函数</a>来捕获当前函数的输出，然后(例如)保存到一个 <span class="type">string</span> 中。</p></div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.var-dump-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">value</code></dt>

     <dd>

      <p class="para">
       要打印的表达式。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">values</code></dt>

     <dd>

      <p class="para">
       更多要打印的表达式。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.var-dump-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.var-dump-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5307">
    <p><strong>示例 #1 <span class="function"><strong>var_dump()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$a&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">"a"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"b"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"c"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(3) {
  [0]=&gt;
  int(1)
  [1]=&gt;
  int(2)
  [2]=&gt;
  array(3) {
    [0]=&gt;
    string(1) &quot;a&quot;
    [1]=&gt;
    string(1) &quot;b&quot;
    [2]=&gt;
    string(1) &quot;c&quot;
  }
}
</pre></div>
    </div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$b&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">3.1</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$c&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$b</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$c</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
float(3.1)
bool(true)
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.var-dump-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.print-r.html" class="function" rel="rdfs-seeAlso">print_r()</a> - 打印人类可读的变量信息</span></li>
    <li class="member"><span class="function"><a href="function.debug-zval-dump.html" class="function" rel="rdfs-seeAlso">debug_zval_dump()</a> - Dumps a string representation of an internal zval structure to output</span></li>
    <li class="member"><span class="function"><a href="function.var-export.html" class="function" rel="rdfs-seeAlso">var_export()</a> - 输出或返回变量的可解析字符串表示</span></li>
    <li class="member"><a href="language.oop5.magic.html#language.oop5.magic.debuginfo" class="link">__debugInfo()</a></li>
   </ul>
  </p>  
 </div>

</div></div></div></body></html>